<template>
  <div>
      <h2>登录页面</h2>
      <table class="table" border="1">
        <tr>
          <td>用户名</td>
          <td><input type="text" v-model="userName"></td>
        </tr>
        <tr>
          <td>密码</td>
          <td>
            <input type="text" v-model="userPwd">
          </td>
        </tr>
        <tr>
          <td colspan="2" style="text-align:center"><input type="button" value="登录" @click="Login"></td>
        </tr>
      </table>
  </div>
</template>

<script setup lang="ts">
  import {reactive,toRefs} from 'vue'
  import {useRouter,useRoute} from 'vue-router'
  let router = useRouter();
  let route = useRoute();
  
  let data=reactive({
    userName:"",
    userPwd:""
  })
  let {userName,userPwd}=toRefs(data)
  function Login()
  {
    if(userName.value=="")
    {
      alert("用户名不能为空");
      return
    }
    if(userPwd.value=="")
    {
      alert("密码不能为空");
      return
    }
    if(userName.value!="admin")
    {
      alert("账户名不存在");
      return
    }
    if(userPwd.value!="admin")
    {
      alert("密码错误");
      return
    }
    alert("登录成功")
    router.push({
      path:"/logsucc",
      query:{
        userName:userName.value,
        userPwd:userPwd.value,
      }
    })
    
  }
</script>

<style scoped>

</style>